package com.tmc.dao.impl.inthotel;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.tmc.bean.inthotel.hotel.CXLPolicies;
import com.tmc.dao.impl.BaseDaoImpl;

@Repository
public class CXLPoliciesDaoImpl extends BaseDaoImpl {

	public void saveAllCXLPolicies (List<CXLPolicies> cXLPolicies){
		Session session = getSession();
    	session.beginTransaction();
		for (int i = 0; i < cXLPolicies.size(); i++) {
			session.save(cXLPolicies.get(i));
		}
		session.getTransaction().commit();
	}
	
	public void updateAllCXLPolicies (List<CXLPolicies> cXLPolicies){
		Session session = getSession();
    	session.beginTransaction();
		for (int i = 0; i < cXLPolicies.size(); i++) {
			session.update(cXLPolicies.get(i));
		}
		session.getTransaction().commit();
	}
	
	public List<CXLPolicies> findAllHotel(){
		Session session = getSession();
		String hql = "from CXLPolicies";
		Query query = session.createQuery(hql);
		List<CXLPolicies> cXLPolicies =(List<CXLPolicies>)query.list();
		session.close();
		return cXLPolicies;
	}
	
}
